/**
 * 详情对话框
 */
var ArchiveInfoInfoDlg = {
    data: {
        wjid: "",
        mc: "",
        dalx: "",
        ssbmid: "",
        ssrrmc: "",
        mj: "",
        glnx: "",
        nd: "",
        qsnd: "",
        jsnd: "",
        dahid: "",
        ly: "",
        bz: "",
        sfyx: ""
    }
};

layui.use(['form', 'admin', 'ax','table','func','element','formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var el = layui.element;
    var fs = layui.formSelects;


    var infoTable = new Info(layui);

    var fileTable = new Files(layui);

    infoTable.setItemSelect(function (index,data) {
        fileTable.setParentId(data.id);
    })


    infoTable.setParentId(Feng.getUrlParam("id"));

    fs.on('dag', function(id, vals, val, isAdd, isDisabled){
        var values = val.value.split("/");
        if(values.length == 4) {
            $("#dahid").val(values[3]);
            return true;
        }
        Feng.error("数据不全，无法选取");
        //如果return false, 那么将取消本次操作
        return false;
    });



    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/archiveInfo/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('archiveInfoForm', result.data);

    //获取档案盒的层级
    var boxData = new $ax(Feng.ctxPath+"/archiveBox/detail?id="+result.data.dahid).start();
    //绑定层级
    fs.value('dag',[boxData.data.ssdasid+"/"+boxData.data.ssdagid+"/"+boxData.data.ssdagcid+"/"+boxData.data.id]);
    fs.value("dalx",[result.data.dalx]);
    fs.value("ssbmid",[result.data.ssbmid]);
    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/archiveInfo/editItem", function (data) {
            Feng.success("更新成功！");
            window.location.href = Feng.ctxPath + '/archiveInfo'
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/archiveInfo'
    });

});